#ifndef LINEARDISCRIMINANTANALYSIS_H
#define LINEARDISCRIMINANTANALYSIS_H

#include <vector>
#include <QDebug>
#include <fstream>
#include "mytype.h"

using namespace std;


class LinearDiscriminantAnalysis
{
public:
    LinearDiscriminantAnalysis(int feat);
    bool loaddata(const char* file);
    ~LinearDiscriminantAnalysis();
private:
    void projectionMat();
    void withinMat(CvMat *classMean, CvMat *within);
    void betweenMat(CvMat *classMean, CvMat *between);
    void ratioMat(CvMat *s_b, CvMat *s_w);
    void classMeanMat(CvMat *mean);
    void totalMeanMat(CvMat *classMean, CvMat *totalMean);
    void covarianceMat(CvMat *classMean, CvMat *scatterMat);

    void processLine(vector<double *> &temp, string &line);
    void storeData(vector<double *> &temp, int rows);
    bool writeData(CvMat *data);

    CvMat *src, *projMat;
    vector<int> *class_info;
    int numClass;       // Number of class
    int f_rows;         // Number of features;
    int d_rows;         // Number of input lines
};

#endif // LINEARDISCRIMINANTANALYSIS_H
